/*********************************************************************************/
#delimit;
cd "C:\Users\ejm5\Dropbox\IDS_PAPI";


/*FDI*/
#delimit;
use "C:\Users\ejm5\Dropbox\PCI 2013\FDI raw data\FDI_GDP.dta", clear;
tset year;
#delimit;
tsline fdi_gdp if year>1985, lwidth(thick) lcolor(navy) xlab(1987(2)2011, labsize(vsmall)) ylab(0(1)12, labsize(small)) ytitle("FDI Inflows/GDP (%)", size(medium) margin(medium)) xtitle("") 
xline(2001 2007, lwidth(medithick) lpattern(dash) lcolor(maroon));



use "C:\Users\ejm5\Dropbox\PCI 2013 (1)\DDI raw data\core_pci_2013.dta", clear
collapse (mean) t_unweighted tsub3_ if year>2005 & year<2011, by(pci_id year)
xtset pci_id year
tsline tsub3_trans, by(pci_id) xtitle("") ytitle("") xlab(2006(2)2010, labsize(small)) note("") ylab(3(2)7, labsize(small))
tsline t_unweighted, by(pci_id) xtitle("") ytitle("") xlab(2006(2)2010, labsize(medsmall)) note("") ylab(40(10)60, labsize(medsmall)) note("", size(tiny))

#delimit;
use "C:\Users\ejm5\Dropbox\PCI 2013 (1)\DDI raw data\core_pci_2013.dta", clear;
drop if year>2010;
pwcorr t_unweighted l.t_un l2.t_un l3.t_un l4.t_un l5.t_un l6.t_un, star(5);
pwcorr tsub3 l.tsub3 l2.tsub3 l3.tsub3 l4.tsub3 l5.tsub3, star(5);
tabstat t_unweighted tsub3, by(year) stat(min med max sd);


collapse (mean) t_unweighted tsub3 planning_avg legal_avg f2_new f6_new g4_new web_04 
		  (sd)  sd_un=t_unweighted sd_trans=tsub3 sd_plan=planning_avg sd_legal=legal_avg sd_f2=f2_new sd_f6=f6_new sd_g4=g4_new sd_web04=web_04  if year>2005 & year<2011, by(pci_id);

		  
		  
		 		  
generate cv_unweighted= sd_un/ t_unweighted;
#delimit;
generate cv_trans=sd_trans/tsub3;
generate cv_planning=sd_plan/planning_avg;
generate cv_legal=sd_legal/legal_avg;
generate cv_f2=sd_f2/f2;
generate cv_f6=sd_f6/f6;
generate cv_g4=sd_g4/g4;
generate cv_web=sd_web/web;

tabstat cv_unweighted cv_trans cv_planning cv_legal cv_f2 cv_f6 cv_g4 cv_web , stat(min med max sd) ;
